//
//  PKRadioTableViewCell.m
//  PianKe
//
//  Created by lanou on 15/10/4.
//  Copyright (c) 2015年 lanou. All rights reserved.
//

#import "PKRadioTableViewCell.h"
#import <UIImageView+WebCache.h>
@implementation PKRadioTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
   self= [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _coverImage=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
        [self.contentView addSubview:_coverImage];
        _titleLable=[[UILabel alloc]initWithFrame:CGRectMake(120, 0,200 , 30)];
        _titleLable.font=[UIFont systemFontOfSize:18];
        [self.contentView addSubview:_titleLable];
        
        _authorLabel=[[UILabel alloc]initWithFrame:CGRectMake(120, 35, 200, 30)];
        [self.contentView addSubview:_authorLabel];
        _authorLabel.font=[UIFont systemFontOfSize:12];
        _descLabel=[[UILabel alloc]initWithFrame:CGRectMake(120, 70, 200, 30)];
        _descLabel.numberOfLines=0;
        _descLabel.font=[UIFont systemFontOfSize:12];
        [self.contentView addSubview:_descLabel];
    }
    return self;
}
#warning 通过set方法对cell类视图进行赋值
-(void)setRadioMainListModel:(PKRadioMainListModel *)radioMainListModel
{
    _radioMainListModel=radioMainListModel;
    [_coverImage sd_setImageWithURL:[NSURL URLWithString:radioMainListModel.coverimg]];
    
    _titleLable.text=radioMainListModel.title;
    _authorLabel.text= [@"by:"  stringByAppendingString:radioMainListModel.userinfo.uname] ;
    
    _descLabel.text=radioMainListModel.desc;
    CGFloat heigth =   [PKRadioTableViewCell heigthforDesString:radioMainListModel.desc];
    _descLabel.frame=CGRectMake(120, 70, 200, heigth);
}
- (void)awakeFromNib {
    // Initialization code
}
#warning 自定义description的高度
+(CGFloat)heigthforDesString:(NSString*)descrition
{
    NSDictionary *dict =[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:12] forKey:NSFontAttributeName];
 CGRect  frame=   [descrition boundingRectWithSize:CGSizeMake(200, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:dict context:nil];
    return frame.size.height;
}
+(CGFloat )heigthForCell:(PKRadioMainListModel *)radioMainListModel
{
    
    CGFloat height=[PKRadioTableViewCell heigthforDesString:radioMainListModel.description]+70;
    if (height >110) {
        return height;
    }
    else
    {
        return 110;
    }
//return <#expression#>
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
